 $(document).ready(function(){
           var ajaxLoading=false;
            $(".users").css("margin-right","15px");
      var himnakan_tiv;
//      if($.client.browser=="Chrome" ){
//          //265
//           himnakan_tiv=$("#header").height()+$("#menuLay").height()+$("#footer").height()+2*30+80+2*10;
//      }else{
//          //312
//
//      }
     himnakan_tiv=$("#header").height()+$("#menuLay").height()+$("#footer").height()+2*25+80+2*10;
     //alert(himnakan_tiv);
           $("#content").css("min-height",($(window).height()-himnakan_tiv));
           $("#deviceInfo").css("min-height",($(window).height()-himnakan_tiv));

         // alert($(window).height()+" " +  $("#content").height())   ;

            $('.network').click(function(){
              if (!ajaxLoading) {
                 ajaxLoading = true;
                 var obj = $(".subNetwork");
                 var count = $(".subNetwork").find("li").length;
                 if(count==0){
                     $.ajax({
                        url:'viewNetworks.action',
                        cache:false,
                        type:'POST',
                             success:function(result){
                                 ajaxLoading = false;
                                 $("#allNetworks").attr("src",'images/content/network_storage.png')  ;
                                 obj.html(result);
                                 var networkHeightInt=parseFloat($("#networks").css("height").split("p")[0]);
                                 var contentHeightInt=parseFloat($("#content").css("height").split("p")[0]);
                                 $("#content").css("height",contentHeightInt>networkHeightInt?contentHeightInt:networkHeightInt) ;
                                    contentHeightInt=parseFloat($("#content").css("height").split("p")[0]);
                                  }
                        });
                    }
                   else {
                                var t= $(".subNetwork").find("input[name='isHidden']").val();
                                if($(".subNetwork").find("input[name='isHidden']").val()==1){
                                       $("#items").show();
                                       $("#allNetworks").attr("src",'images/content/network_storage.png');
                                       var li=$(".subNetwork").find("li");
                                          li.each(function(){
                                          li.attr("disable","false");
                                       }) ;
                                      $(".subNetwork").find("input[name='isHidden']").val(0);
                                      var networkId=$(".selecting").parent().find("input[name='networkId']").val();
                                      var deviceSerial=$("input[name='selectedDevice']").val();

                                      if(networkId!=null){
                                         if(deviceSerial!="") {
                                                  $.ajax({
                                                    url: "viewDeviceInfo.action",
                                                    data:{
                                                        serial:deviceSerial
                                                         },
                                                    cache:false,
                                                    type:"post",
                                                    success:function(data) {
                                                        ajaxLoading = false;
                                                        $("#deviceInfo").html(data);

                                                    }
                                                });
                                         } else {

                                                $.ajax({
                                                    url: "viewDevices.action",
                                                    data:"networkId="+networkId,
                                                    cache:false,
                                                    type:"post",
                                                    success:function(data) {
                                                        ajaxLoading = false;
                                                        $("#deviceInfo").html(data);
                                                        $(".dataTables_empty").text("There is no device in this network");
                                                      }
                                              });
                                         }
                                     }
                                   }
                                else{
                                    $("#items").hide();
                                    $("#allNetworks").attr("src",'images/content/network.png');
                                    var li=$(".subNetwork").find("li");
                                    li.each(function(){
                                        li.attr("disable","true");
                                    }) ;
                                    $(".subNetwork").find("input[name='isHidden']").val(1);
                                    ajaxLoading = false;
                                }
                               $("#deviceInfo").html("");
                               var networkHeightInt=parseFloat($("#networks").css("height").split("p")[0]);
                                   $("#content").css("height",networkHeightInt>600?networkHeightInt:600) ;
                    }
              }
              });


            var clicking=0;
            $(".eachNetworkName").live("click",function(){
             if (!ajaxLoading) {
               ajaxLoading = true;
               clicking=1;
               var item=$(this);
               item.attr({disabled:true});
                var allLi=$(this).parent().parent().find(".eachNetworkName").removeClass("selecting");
                $(this).addClass("selecting") ;
                var networkId=$(this).parent().find("input[name='networkId']").val();
                $("#deviceInfo").html("");
                       $.ajax({
                                url: "viewDevices.action",
                                data:"networkId="+networkId,
                                type:"post",
                                success:function(data) {

                                   $("#deviceInfo").html(data);
                                   $(".dataTables_empty").text("There is not any device");
                                     item.attr({disabled:false});
                                   $("input[name='selectedDevice']").val("");

                                   //added for explorer 7
                                        $("#items").show();
                                        $("#allNetworks").attr("src",'images/content/network_storage.png');
                                        var li=$(".subNetwork").find("li");
                                          li.each(function(){
                                          li.attr("disable","false");
                                        }) ;
                                       $(".subNetwork").find("input[name='isHidden']").val(0);
                                     //added for explorer 7
                                }
                      });
                 ajaxLoading=false;
               }
             })
});